<?php

namespace app\admin\controller\goods;

use app\common\controller\AdminController;
use app\common\service\RedisService;
use EasyAdmin\annotation\ControllerAnnotation;
use EasyAdmin\annotation\NodeAnotation;
use think\App;
use think\facade\Db;

/**
 * @ControllerAnnotation(title="商品分类")
 */
class Category extends AdminController
{

    use \app\admin\traits\Curd;

    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->model = new \app\admin\model\GoodsCategory();
        
    }


    /**
     * @NodeAnotation(title="推送:同步")
     */
    public function sync(){
        $list = Db::query("SELECT * FROM sy_goods_category");
        $data = collection($list)->toArray();

        RedisService::select(3)->set( self::KEYS['CATEGORY_LIST'], json_encode($data, JSON_UNESCAPED_UNICODE) );
    }
    
}